package org.webequa.core.maple.manager;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.maplesoft.openmaple.Engine;
import com.maplesoft.openmaple.EngineCallBacksDefault;
import com.maplesoft.externalcall.MapleException;

public class MapleSupervisor
{
	public static int getVarId()
	{
		mapleVarId ++;
		return mapleVarId;
	}
	
	public static String getVarIdName()
	{
		return varPrefix+getVarId();
	}
	
	public static synchronized Engine getMapleEngine()
	{
		if (mapleEngine!=null)
			return mapleEngine;
		else
		{
		  try
			{
				String mapleArgs[];
			  mapleArgs = new String[1];
			  mapleArgs[0] = "java";
		  	mapleEngine = new Engine(mapleArgs, new EngineCallBacksDefault(), null, null);
		  	return mapleEngine;
			} catch (MapleException e)
			{
				log.error("Get maple engine - ",e);
				return null;
			}
		}
	}
	
	public static Engine mapleEngine;
	public static int mapleVarId = 0;
	public static String varPrefix = "scilab_qnty_";
	private static final Logger log = LoggerFactory.getLogger(MapleSupervisor.class);

}
